//
//  Home_Set_TimeZoneCell.m
//  HuaRun2
//
//  Created by admin on 17/9/5.
//  Copyright © 2017年 Sunny. All rights reserved.
//

#import "Home_Set_TimeZoneCell.h"
#import "Home_Set_TimeZoneModel.h"

@implementation Home_Set_TimeZoneCell
#pragma mark - life cycle

- (void)dealloc {
    NSLog(@"%@ dealloc", [self class]);
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self viewInit];
        [self layoutInit];
    }
    return self;
}

- (void)viewInit {

    [self.contentView addSubview:self.flagView];

    [self.contentView addSubview:self.valueLab1];
    
}

- (void)layoutInit {
    
    weakself(ws);
    
    [self.flagView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(ws.contentView);
        make.left.mas_equalTo(ws.contentView).offset(0);
        make.size.mas_equalTo(CGSizeMake(15, 10));
    }];
    
    [self.valueLab1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(ws.contentView);
        make.left.mas_equalTo(ws.flagView.mas_right).offset(0);
        make.right.mas_equalTo(ws.contentView).offset(0);
        make.height.mas_equalTo(ws.contentView);
    }];
    
}

#pragma mark getter setter
- (void)setZoneModel:(Home_Set_TimeZoneModel *)zoneModel {
    _zoneModel = zoneModel;
    _valueLab1.text = [NSString showSpaceStringWithStr: _zoneModel.value];
    if (zoneModel.isSelectedStatus) {
        _valueLab1.textColor = RGBA(243, 161, 50, 1);
    }else {
        _valueLab1.textColor = [UIColor colorWithHex:@"3c3c3c"];
    }
    _flagView.hidden = !zoneModel.isSelectedStatus;
}

- (UILabel *)valueLab1 {
    if (!_valueLab1) {
        self.valueLab1 = [UILabel new];
        _valueLab1.textAlignment = NSTextAlignmentLeft;
        _valueLab1.font = kGeneralFontSize;
        _valueLab1.textColor = [UIColor colorWithHex:@"3c3c3c"];
        _valueLab1.text = @"英文民";
//        _valueLab1.backgroundColor = kRandomColor;
    }
    return _valueLab1;
}

- (UIImageView *)flagView {
    if (!_flagView) {
        self.flagView = [UIImageView new];
        _flagView.image = [UIImage imageNamed:@"save_yanse"];
        _flagView.hidden = YES;
    }
    return _flagView;
}
@end
